from flask import Blueprint, render_template, request, jsonify, abort
from models.my_model import Post, R
from sqlalchemy import func

page_template = Blueprint("template", __name__)


@page_template.route("/_temp")
def temp():
    msg: str = "Yes!"
    return render_template("TEMPLATE.html", msg=msg)
    # return jsonify(R(code=200, msg="OKKKKK", data={"data": "121212"}).define())


@page_template.route("/_t1")
def temp1():
    msg: str = "Yes!"
    return render_template("error_with_msg.html", msg=msg)
    # return jsonify(R(code=200, msg="OKKKKK", data={"data": "121212"}).define())

@page_template.route("/_t2")
def temp2():
    msg: str = "YesONOJSIODSIODJIOS!"
    return render_template("with_msg.html", msg=msg)
    # return jsonify(R(code=200, msg="OKKKKK", data={"data": "121212"}).define())

@page_template.route("/_t401")
def t401():
    abort(401)
    return render_template("with_msg.html", msg=msg)
    # return jsonify(R(code=200, msg="OKKKKK", data={"data": "121212"}).define())

@page_template.errorhandler(401)
def errorhandler_401(error):
    return render_template("TEMPLATE.html", msg=error), 401


